---
category: DOM
created: '2020-04-19'
title: Get the selected text
updated: '2021-10-13'
---

**JavaScript version**

```js getSelectedText.js
const getSelectedText = () => window.getSelection().toString();
```
